<% content_for :sitemap do %>
  <span class="current"><%= t('admin.menu.replies') %></span>
<% end %>
<div class="toolbar">
  <form class="form-inline" action="<%= admin_replies_path %>">
    <input type="text" name="q" class="form-control" value="<%= params[:q] %>" placeholder="Title">
    <input type="text" name="login" class="form-control" value="<%= params[:login] %>" placeholder="Username">
    <button class="btn btn-secondary">Search</button>
  </form>
</div>
<table class="table table-bordered table-striped table-condensed">
  <tr class="head">
    <th class="first">#</th>
    <th style="width:500px">Body</th>
    <th>Topic</th>
    <th>Creator</th>
    <th>Time</th>
    <th></th>
  </tr>
  <% @replies.each do |reply| %>
    <tr id="reply-<%= reply.id %>" class="<%= 'deleted' if !reply.deleted_at.blank? %>">
      <td class="first"><%= reply.id %></td>
      <td><%= truncate(reply.body, length: 50) %></td>
      <% if reply.topic %>
        <td>
          <%= link_to(reply.topic_id, topic_path(reply.topic_id), title: reply.topic.title)%>
        </td>
      <% else %>
        <td><%= reply.topic_id %></td>
      <% end %>
      <td><%= link_to(reply.user.login, edit_admin_user_path(reply.user_id), target: "_blank") if reply.user %></td>
      <td><%= l reply.created_at, format: :short %></td>
      <td class="actions">
        <div class="btn-group">
        <%= link_to icon_tag("edit"), edit_admin_reply_path(reply), class: "btn" %>
        <% if reply.deleted_at.blank? %>
          <%= link_to icon_tag("trash"), admin_reply_path(reply), 'data-confirm' => 'Are you sure?', method: :delete, remote: true, class: "btn" %>
        <% else %>
          <%= link_to icon_tag("undo"), revert_admin_reply_path(reply), title: t("common.revert"), 'data-confirm' => 'Are you sure?', method: :post, class: "btn" %>
        <% end %>
      </td>
    </tr>
  <% end %>
</table>
<%= paginate @replies %>
